package com.shu.socket.multicast.multicast;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.*;
import java.util.concurrent.TimeUnit;

/**
 * @author ssm
 * @version V1.0
 * @description:
 * @date 2019/2/20 19:40
 */

public class SocketServer {

  public static void main(String[] args) throws IOException {

    try {
      InetAddress group = InetAddress.getByName("224.5.6.7");

      MulticastSocket socket = new MulticastSocket();

      for (int i = 0; i < 10; i++) {
        String data = "hello client";
        byte[] bytes = data.getBytes();
        socket.send(new DatagramPacket(bytes,bytes.length,group,8888));
        TimeUnit.SECONDS.sleep(2);
      }
    } catch (InterruptedException e) {
      e.printStackTrace();
    }


  }
}
